<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:include page="global.jsp"></jsp:include>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>售后记录管理</title>
<style type="text/css">
.ctl{
	text-decoration: none;
	color: blue;
	margin: auto 7px;
}
.ctl:HOVER{
	text-decoration: underline;
}
.center{
	text-align: center;
}
</style>
</head>
<body>
	<table id="dg" class="easyui-datagrid" title="售后记录管理"
			data-options="
				rownumbers:true,
				iconCls: 'icon-edit',
				singleSelect: true,
				toolbar: '#tb',
				singleSelect:true,
				pagination:true,
				fit:true,
				fitColumns:true,
				pageList:[20,25,30,35,40,45,50],
				pageSize:20
			">
		<thead>
			<tr>
				<th data-options="field:'projectName',width:100,align:'center'">项目名称</th>
				<th data-options="field:'productName',width:100,align:'center'">产品名称</th>
				<th data-options="field:'cusName',width:100,align:'center'">客户</th>
				<th data-options="field:'customerName',width:100,align:'center'">客户名称</th>
				<th data-options="field:'contactPerson',width:60,align:'center'">联系人</th>
				<th data-options="field:'contactPersonTel',width:80,align:'center'">联系方式</th>
				<th data-options="field:'outOfWarrantySign',width:40,align:'center'">是否过保</th>
				<th data-options="field:'registerTime',width:100,align:'center'">登记日期</th>
				<th data-options="field:'expectFinishDate',width:100,align:'center'">期望完成日期</th>
				<th data-options="field:'status',width:40,align:'center'">状态</th>
				<th data-options="field:'id',width:100,align:'center',formatter:formatControl">管理</th>
			</tr>
		</thead>
	</table>

	<div id="tb" style="height:auto">
		<div>
			<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="clearForm('form', 'addItem')">新增</a>
		</div>
		<div>
			项目名称:
			<select id = "project" class="easyui-combobox" data-options="editable: false">
				<option value = "-1"> --全部-- </option>
				<c:forEach var="item" items="${projects }" >
					<option value = "${item.id }">${item.name }</option>
				</c:forEach>
			</select>
			关联产品:
			<select id = "product" class="easyui-combobox" data-options="editable: false">
				<option value = "-1"> --全部-- </option>
				<c:forEach var="item" items="${products }" >
					<option value = "${item.id }">${item.name }</option>
				</c:forEach>
			</select>
			客户名称:
			<select id = "customer" class="easyui-combobox" data-options="editable: false">
				<option value = "-1"> --全部-- </option>
				<c:forEach var="item" items="${customers }" >
					<option value = "${item.id }">${item.name }</option>
				</c:forEach>
			</select>
			处理类型:
			<select id = "aftersaleHandleType" class="easyui-combobox" data-options="editable: false">
				<option value = "-1"> --全部-- </option>
				<c:forEach var="item" items="${aftersaleHandleTypes }" >
					<option value = "${item.id }">${item.name }</option>
				</c:forEach>
			</select>
			登记人:
			<select id = "registerPerson" class="easyui-combobox" data-options="editable: false">
				<option value = "-1"> --全部-- </option>
				<c:forEach var="item" items="${persons }" >
					<option value = "${item.id }">${item.name }</option>
				</c:forEach>
			</select>
			处理人:
			<select id = "handlePerson" class="easyui-combobox" data-options="editable: false">
				<option value = "-1"> --全部-- </option>
				<c:forEach var="item" items="${persons }" >
					<option value = "${item.id }">${item.name }</option>
				</c:forEach>
			</select>
			审核人:
			<select id = "checkPerson" class="easyui-combobox" data-options="editable: false">
				<option value = "-1"> --全部-- </option>
				<c:forEach var="item" items="${persons }" >
					<option value = "${item.id }">${item.name }</option>
				</c:forEach>
			</select>
			登记日期: <input class="easyui-datebox" type="text" id="registerTimeBegin" style="width:100px;height:25px;">
			~ <input class="easyui-datebox" type="text" id="registerTimeEnd" style="width:100px;height:25px;">
			<a href="javascript:search()" class="easyui-linkbutton" iconCls="icon-search">查 找</a>
		</div>
	</div>
	
	<div id="lookDetail" class="easyui-window" title="售后记录详情" data-options="modal:true,closed:true,iconCls:'icon-search'" style="width:1100px; height:450px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;">
				<table width="100%" height="100%">
						<tr>
							<td width="200px;" align="right">项目名称：</td>
							<td width="160px">
								<select id="lookProjectId" class="easyui-combobox" data-options="required:true" disabled="disabled">
									<c:forEach var="item" items="${projects }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td width="130px;" align="right">关联产品：</td>
							<td>
								<select id="lookProductId" class="easyui-combobox" data-options="required:true" disabled="disabled">
									<c:forEach var="item" items="${products }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td width="160px;"  align="right">状态：</td>
							<td>
								<input class="easyui-textbox" id="lookStatus" data-options="required:true" />
							</td>
						</tr>
						<tr>
							<td width="130px;" align="right">登记人：</td>
							<td width="160px">
								<select id="lookRegisterPersonId" class="easyui-combobox" data-options="required:true" disabled="disabled">
									<c:forEach var="item" items="${persons }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td align="right">是否过保：</td>
							<td>
								<input class="easyui-textbox" id="lookOutOfWarrantySign" data-options="required:true" readonly="readonly" />
							</td>
							<td align="right">登记日期：</td>
							<td>
								<input class="easyui-datebox" id="lookRegisterTime" data-options="required:true" readonly="readonly" />
							</td>
						</tr>
						<tr>
							<td align="right">产品序列号：</td>
							<td>
								<input class="easyui-textbox" id="lookProductSequenceNo" data-options="required:true" readonly="readonly" />
							</td>
							<td align="right">联系人：</td>
							<td>
								<input class="easyui-textbox" id="lookContactPerson" data-options="required:true" readonly="readonly" />
							</td>
							<td align="right">联系方式：</td>
							<td>
								<input class="easyui-textbox" id="lookContactPersonTel" data-options="required:true" readonly="readonly" />
							</td>
						</tr>
						<tr>
							<td width="200px;" align="right">问题描述：</td>
							<td colspan="5">
								<input class="easyui-textbox" data-options="multiline:true, required:true" style="width: 890px; height: 80px;" id="lookIssueDescription" readonly="readonly">
							</td>
						</tr>
						<tr>
							<td align="right">期望完成日期：</td>
							<td>
								<input class="easyui-datebox" id="lookExpectFinishDate" data-options="required:true" readonly="readonly" />
							</td>
							<td width="130px;" align="right">客户：</td>
							<td width="160px">
								<select id="lookCusId" class="easyui-combobox" data-options="required:true" disabled="disabled">
									<c:forEach var="item" items="${customers }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td align="right">客户名称：</td>
							<td>
								<input class="easyui-textbox" id="lookCustomerName" data-options="required:true" readonly="readonly" />
							</td>
						</tr>
						<tr>
							<td width="130px;" align="right">处理人：</td>
							<td>
								<select id="lookHandlePersonId" class="easyui-combobox" disabled="disabled">
									<c:forEach var="item" items="${persons }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td width="130px;" align="right">处理类型：</td>
							<td>
								<select id="lookAftersaleHandleTypeId" class="easyui-combobox" disabled="disabled">
									<c:forEach var="item" items="${aftersaleHandleTypes }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td align="right">返修日期：</td>
							<td>
								<input class="easyui-datebox" id="lookReturnDate" readonly="readonly" />
							</td>
						</tr>
						<tr>
							<td align="right">问题原因：</td>
							<td colspan="5">
								<input class="easyui-textbox" data-options="multiline:true" style="width: 890px; height: 80px;" id="lookIssueReason" readonly="readonly">
							</td>
						</tr>
						<tr>
							<td align="right">处理描述：</td>
							<td colspan="5">
								<input class="easyui-textbox" data-options="multiline:true" style="width: 890px; height: 80px;" id="lookHandleDescription" readonly="readonly">
							</td>
						</tr>
						<tr>
							<td align="right" rowspan="2">维修成本说明：</td>
							<td colspan="3" rowspan="2">
								<input class="easyui-textbox" data-options="multiline:true" style="width: 450px; height: 80px;" id="lookHandleCostDescription" readonly="readonly">
							</td>
							<td align="right">维修费用：</td>
							<td>
								<input class="easyui-textbox" id="lookHandleFee" readonly="readonly" />
							</td>
						</tr>
						<tr>
							<td align="right">维修成本：</td>
							<td>
								<input class="easyui-textbox" id="lookHandleCost" readonly="readonly" />
							</td>
						</tr>
						<tr>
							<td width="130px;" align="right">审核人：</td>
							<td width="160px">
								<select id="lookCheckPersonId" class="easyui-combobox" disabled="disabled">
									<c:forEach var="item" items="${persons }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td align="right">审核日期：</td>
							<td>
								<input class="easyui-datebox" id="lookCheckTime" readonly="readonly" />
							</td>
							<td align="right">实际完成日期：</td>
							<td>
								<input class="easyui-datebox" id="lookActualFinishTime" readonly="readonly" />
							</td>
						</tr>
						<tr>
							<td align="right">售后处理工时：</td>
							<td>
								<input class="easyui-textbox" id="lookConsumeWorktime" readonly="readonly" />
							</td>
							<td align="right">修好日期：</td>
							<td>
								<input class="easyui-datebox" id="lookFinishDate" readonly="readonly" />
							</td>
							<td align="right">交付日期：</td>
							<td>
								<input class="easyui-datebox" id="lookDeliveryDate" readonly="readonly" />
							</td>
						</tr>
						<tr>
							<td align="right">备注：</td>
							<td colspan="5">
								<input class="easyui-textbox" data-options="multiline:true" style="width: 890px; height: 80px;" id="lookRemark" readonly="readonly">
							</td>
						</tr>
				</table>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="javascript:$('#lookDetail').window('close')" style="width:80px">关 闭</a>
			</div>
		</div>
	</div>
	
	<div id="addItem" class="easyui-window" title="新增售后记录" data-options="modal:true,closed:true,iconCls:'icon-search'" style="width:1100px; height:450px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;">
				<form id="form" method="post" action="editAftersaleRecord" style = "width:100%; height: 100%">
					<table width="100%" height="100%">
						<tr>
							<td width="200px;" align="right">项目名称：</td>
							<td width="160px">
								<select name = "project.id" class="easyui-combobox" data-options="required:true, editable: false">
									<c:forEach var="item" items="${projects }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td width="130px;" align="right">关联产品：</td>
							<td>
								<select name = "product.id" class="easyui-combobox" data-options="required:true, editable: false">
									<c:forEach var="item" items="${products }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td width="130px;"  align="right">状态：</td>
							<td>
								<input class="easyui-textbox" name="status" data-options="required:true" />
							</td>
						</tr>
						<tr>
							<td width="130px;" align="right">登记人：</td>
							<td width="160px">
								<select name = "registerPerson.id" class="easyui-combobox" data-options="required:true, editable: false">
									<c:forEach var="item" items="${persons }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td align="right">是否过保：</td>
							<td>
								<input class="easyui-textbox" name="outOfWarrantySign" data-options="required:true" />
							</td>
							<td align="right">登记日期：</td>
							<td>
								<input class="easyui-datebox" name="registerTime" data-options="required:true" />
							</td>
						</tr>
						<tr>
							<td align="right">产品序列号：</td>
							<td>
								<input class="easyui-textbox" name="productSequenceNo" data-options="required:true" />
							</td>
							<td align="right">联系人：</td>
							<td>
								<input class="easyui-textbox" name="contactPerson" data-options="required:true" />
							</td>
							<td align="right">联系方式：</td>
							<td>
								<input class="easyui-textbox" name="contactPersonTel" data-options="required:true" />
							</td>
						</tr>
						<tr>
							<td align="right">问题描述：</td>
							<td colspan="5">
								<input class="easyui-textbox" data-options="multiline:true, required:true" style="width: 870px; height: 80px;" name="issueDescription">
							</td>
						</tr>
						<tr>
							<td align="right">期望完成日期：</td>
							<td>
								<input class="easyui-datebox" name="expectFinishDate" data-options="required:true" />
							</td>
							<td width="130px;" align="right">客户：</td>
							<td width="160px">
								<select name = "customer.id" class="easyui-combobox" data-options="required:true, editable: false">
									<c:forEach var="item" items="${customers }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td align="right">客户名称：</td>
							<td>
								<input class="easyui-textbox" name="customerName" data-options="required:true" />
							</td>
						</tr>
						<tr>
							<td width="130px;" align="right">处理人：</td>
							<td>
								<select name = "handlePerson.id" class="easyui-combobox" data-options="editable: false">
									<c:forEach var="item" items="${persons }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td width="130px;" align="right">处理类型：</td>
							<td>
								<select name = "aftersaleHandleType.id" class="easyui-combobox" data-options="editable: false">
									<c:forEach var="item" items="${aftersaleHandleTypes }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td align="right">返修日期：</td>
							<td>
								<input class="easyui-datebox" name="returnDate" />
							</td>
						</tr>
						<tr>
							<td align="right">问题原因：</td>
							<td colspan="5">
								<input class="easyui-textbox" data-options="multiline:true" style="width: 870px; height: 80px;" name="issueReason">
							</td>
						</tr>
						<tr>
							<td align="right">处理描述：</td>
							<td colspan="5">
								<input class="easyui-textbox" data-options="multiline:true" style="width: 870px; height: 80px;" name="handleDescription">
							</td>
						</tr>
						<tr>
							<td align="right" rowspan="2">维修成本说明：</td>
							<td colspan="3" rowspan="2">
								<input class="easyui-textbox" data-options="multiline:true" style="width: 450px; height: 80px;" name="handleCostDescription">
							</td>
							<td align="right">维修费用：</td>
							<td>
								<input class="easyui-textbox" name="handleFee" />
							</td>
						</tr>
						<tr>
							<td align="right">维修成本：</td>
							<td>
								<input class="easyui-textbox" name="handleCost" />
							</td>
						</tr>
						<tr>
							<td width="130px;" align="right">审核人：</td>
							<td width="160px">
								<select name = "checkPerson.id" class="easyui-combobox" data-options="editable: false">
									<c:forEach var="item" items="${persons }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td align="right">审核日期：</td>
							<td>
								<input class="easyui-datebox" name="checkTime" />
							</td>
							<td align="right">实际完成日期：</td>
							<td>
								<input class="easyui-datebox" name="actualFinishTime" />
							</td>
						</tr>
						<tr>
							<td align="right">售后处理工时：</td>
							<td>
								<input class="easyui-textbox" name="consumeWorktime" />
							</td>
							<td align="right">修好日期：</td>
							<td>
								<input class="easyui-datebox" name="finishDate" />
							</td>
							<td align="right">交付日期：</td>
							<td>
								<input class="easyui-datebox" name="deliveryDate" />
							</td>
						</tr>
						<tr>
							<td align="right">备注：</td>
							<td colspan="5">
								<input class="easyui-textbox" data-options="multiline:true" style="width: 870px; height: 80px;" name="remark">
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="$('#form').submit()" style="width:80px">确 定</a>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="javascript:$('#addItem').window('close')" style="width:80px">关 闭</a>
			</div>
		</div>
	</div>
	
	<div id="editItem" class="easyui-window" title="编辑售后记录" data-options="modal:true,closed:true,iconCls:'icon-search'" style="width:1100px; height:450px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;">
				<form id="editForm" method="post" action="editAftersaleRecord" style = "width:100%; height: 100%">
					<input type="hidden" id="editId" name = "id">
					<table width="100%" height="100%">
						<tr>
							<td width="200px;" align="right">项目名称：</td>
							<td width="160px">
								<select name = "project.id" id="editProjectId" class="easyui-combobox" data-options="required:true , editable: false">
									<c:forEach var="item" items="${projects }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td width="130px;" align="right">关联产品：</td>
							<td>
								<select name = "product.id" id="editProductId" class="easyui-combobox" data-options="required:true , editable: false">
									<c:forEach var="item" items="${products }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td width="130px;"  align="right">状态：</td>
							<td>
								<input class="easyui-textbox" name="status" id="editStatus" data-options="required:true" />
							</td>
						</tr>
						<tr>
							<td width="130px;" align="right">登记人：</td>
							<td width="160px">
								<select name = "registerPerson.id" id="editRegisterPersonId" class="easyui-combobox" data-options="required:true , editable: false">
									<c:forEach var="item" items="${persons }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td align="right">是否过保：</td>
							<td>
								<input class="easyui-textbox" name="outOfWarrantySign" id="editOutOfWarrantySign" data-options="required:true" />
							</td>
							<td align="right">登记日期：</td>
							<td>
								<input class="easyui-datebox" name="registerTime" id="editRegisterTime" data-options="required:true" />
							</td>
						</tr>
						<tr>
							<td align="right">产品序列号：</td>
							<td>
								<input class="easyui-textbox" name="productSequenceNo" id="editProductSequenceNo" data-options="required:true" />
							</td>
							<td align="right">联系人：</td>
							<td>
								<input class="easyui-textbox" name="contactPerson" id="editContactPerson" data-options="required:true" />
							</td>
							<td align="right">联系方式：</td>
							<td>
								<input class="easyui-textbox" name="contactPersonTel" id="editContactPersonTel" data-options="required:true" />
							</td>
						</tr>
						<tr>
							<td align="right">问题描述：</td>
							<td colspan="5">
								<input class="easyui-textbox" data-options="multiline:true, required:true" style="width: 870px; height: 80px;" name="issueDescription" id="editIssueDescription">
							</td>
						</tr>
						<tr>
							<td align="right">期望完成日期：</td>
							<td>
								<input class="easyui-datebox" name="expectFinishDate" id="editExpectFinishDate" data-options="required:true" />
							</td>
							<td width="130px;" align="right">客户：</td>
							<td width="160px">
								<select name = "customer.id" id="editCusId" class="easyui-combobox" data-options="required:true , editable: false">
									<c:forEach var="item" items="${customers }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td align="right">客户名称：</td>
							<td>
								<input class="easyui-textbox" name="customerName" id="editCustomerName" data-options="required:true" />
							</td>
						</tr>
						<tr>
							<td width="130px;" align="right">处理人：</td>
							<td>
								<select name = "handlePerson.id" id="editHandlePersonId" class="easyui-combobox" data-options="editable: false">
									<c:forEach var="item" items="${persons }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td width="130px;" align="right">处理类型：</td>
							<td>
								<select name = "aftersaleHandleType.id" id="editAftersaleHandleTypeId" class="easyui-combobox" data-options="editable: false">
									<c:forEach var="item" items="${aftersaleHandleTypes }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td align="right">返修日期：</td>
							<td>
								<input class="easyui-datebox" name="returnDate" id="editReturnDate" />
							</td>
						</tr>
						<tr>
							<td align="right">问题原因：</td>
							<td colspan="5">
								<input class="easyui-textbox" data-options="multiline:true" style="width: 870px; height: 80px;" name="issueReason" id="editIssueReason">
							</td>
						</tr>
						<tr>
							<td align="right">处理描述：</td>
							<td colspan="5">
								<input class="easyui-textbox" data-options="multiline:true" style="width: 870px; height: 80px;" name="handleDescription" id="editHandleDescription">
							</td>
						</tr>
						<tr>
							<td align="right" rowspan="2">维修成本说明：</td>
							<td colspan="3" rowspan="2">
								<input class="easyui-textbox" data-options="multiline:true" style="width: 450px; height: 80px;" name="handleCostDescription" id="editHandleCostDescription">
							</td>
							<td align="right">维修费用：</td>
							<td>
								<input class="easyui-textbox" name="handleFee" id="editHandleFee" />
							</td>
						</tr>
						<tr>
							<td align="right">维修成本：</td>
							<td>
								<input class="easyui-textbox" name="handleCost" id="editHandleCost" />
							</td>
						</tr>
						<tr>
							<td width="130px;" align="right">审核人：</td>
							<td width="160px">
								<select name = "checkPerson.id" id="editCheckPersonId" class="easyui-combobox" data-options="editable: false">
									<c:forEach var="item" items="${persons }" >
										<option value = "${item.id }">${item.name }</option>
									</c:forEach>
								</select>
							</td>
							<td align="right">审核日期：</td>
							<td>
								<input class="easyui-datebox" name="checkTime" id="editCheckTime" />
							</td>
							<td align="right">实际完成日期：</td>
							<td>
								<input class="easyui-datebox" name="actualFinishTime" id="editActualFinishTime" />
							</td>
						</tr>
						<tr>
							<td align="right">售后处理工时：</td>
							<td>
								<input class="easyui-textbox" name="consumeWorktime" id="editConsumeWorktime" />
							</td>
							<td align="right">修好日期：</td>
							<td>
								<input class="easyui-datebox" name="finishDate" id="editFinishDate" />
							</td>
							<td align="right">交付日期：</td>
							<td>
								<input class="easyui-datebox" name="deliveryDate" id="editDeliveryDate" />
							</td>
						</tr>
						<tr>
							<td align="right">备注：</td>
							<td colspan="5">
								<input class="easyui-textbox" data-options="multiline:true" style="width: 870px; height: 80px;" name="remark" id="editRemark">
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="$('#editForm').submit()" style="width:80px">确 定</a>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="javascript:$('#editItem').window('close')" style="width:80px">关 闭</a>
			</div>
		</div>
	</div>
	
	<script type="text/javascript">
		function formatControl(val, row){
			return '<a class="ctl" href="javascript:void(0)" onclick="lookDetail(' + val + ')">查看</a>'+
			' <a class="ctl" href="javascript:void(0)" onclick="editItem(' + val + ')">编辑</a>'+
			' <a class="ctl" href="javascript:void(0)" onclick="delItem(' + val + ')">删除</a>';
		}
		function search(){
			var dg = $("#dg");
			var project = $("#project").combobox("getValue");
			var product = $("#product").combobox("getValue");
			var customer = $("#customer").combobox("getValue");
			var aftersaleHandleType = $("#aftersaleHandleType").combobox("getValue");
			var register = $("#registerPerson").combobox("getValue");
			var handlePerson = $("#handlePerson").combobox("getValue");
			var checkPerson = $("#checkPerson").combobox("getValue");
			var registerTimeBegin = $("#registerTimeBegin").textbox("getValue").trim();
			var registerTimeEnd = $("#registerTimeEnd").textbox("getValue").trim();
			var url = "queryAftersaleRecord?projectId=" + project + "&productId=" + product + "&customerId=" + customer + "&aftersaleHandleTypeId=" + aftersaleHandleType + "&handlePersonId=" + handlePerson + "&checkPerson=" + checkPerson + "&registerTimeBegin=" + registerTimeBegin + "&registerTimeEnd=" + registerTimeEnd + "&registerPersonId=" + register;
			dg.datagrid('reload', url);
		}
		function lookDetail(id){
			var params = "id=" + id;
			$.ajax({
			  	type: "GET",
			  	url: "delAftersaleRecord",
			  	data: params,
			  	success:function(data){
				  	var val = $.parseJSON(data);
					if(val.success){
						var item = val.data;

						$("#lookRegisterPersonId").combobox("setValue", item.registerPersonId);
						$("#lookProjectId").combobox("setValue", item.projectId);
						$("#lookProductId").combobox("setValue", item.productId);
						$("#lookCusId").combobox("setValue", item.cusId);
						$("#lookHandlePersonId").combobox("setValue", item.handlePersonId);
						$("#lookAftersaleHandleTypeId").combobox("setValue", item.aftersaleHandleTypeId);
						$("#lookCheckPersonId").combobox("setValue", item.checkPersonId);
						$("#lookIssueDescription").textbox("setValue", item.issueDescription);
						$("#lookOutOfWarrantySign").textbox("setValue", item.outOfWarrantySign);
						$("#lookRegisterTime").textbox("setValue", item.registerTime);
						$("#lookExpectFinishDate").textbox("setValue", item.expectFinishDate);
						$("#lookCustomerName").textbox("setValue", item.customerName);
						$("#lookContactPerson").textbox("setValue", item.contactPerson);
						$("#lookContactPersonTel").textbox("setValue", item.contactPersonTel);
						$("#lookStatus").textbox("setValue", item.status);
						$("#lookActualFinishTime").textbox("setValue", item.actualFinishTime);
						$("#lookConsumeWorktime").textbox("setValue", item.consumeWorktime);
						$("#lookProductSequenceNo").textbox("setValue", item.productSequenceNo);
						$("#lookCheckTime").textbox("setValue", item.checkTime);
						$("#lookReturnDate").textbox("setValue", item.returnDate);
						$("#lookFinishDate").textbox("setValue", item.finishDate);
						$("#lookDeliveryDate").textbox("setValue", item.deliveryDate);
						$("#lookIssueReason").textbox("setValue", item.issueReason);
						$("#lookHandleDescription").textbox("setValue", item.handleDescription);
						$("#lookHandleCostDescription").textbox("setValue", item.handleCostDescription);
						$("#lookHandleFee").textbox("setValue", item.handleFee);
						$("#lookHandleCost").textbox("setValue", item.handleCost);
						$("#lookRemark").textbox("setValue", item.remark);
						
						$('#lookDetail').window('open');
					}else{
						$.messager.alert("提示", val.msg, "error");
					}
			  	}
			});
		}
		function editItem(id){
			var params = "id=" + id;
			$.ajax({
			  	type: "GET",
			  	url: "delAftersaleRecord",
			  	data: params,
			  	success:function(data){
				  	var val = $.parseJSON(data);
					if(val.success){
						var item = val.data;

						$("#editId").val(id);
						$("#editRegisterPersonId").combobox("setValue", item.registerPersonId);
						$("#editProjectId").combobox("setValue", item.projectId);
						$("#editProductId").combobox("setValue", item.productId);
						$("#editCusId").combobox("setValue", item.cusId);
						$("#editHandlePersonId").combobox("setValue", item.handlePersonId);
						$("#editAftersaleHandleTypeId").combobox("setValue", item.aftersaleHandleTypeId);
						$("#editCheckPersonId").combobox("setValue", item.checkPersonId);
						$("#editIssueDescription").textbox("setValue", item.issueDescription);
						$("#editOutOfWarrantySign").textbox("setValue", item.outOfWarrantySign);
						$("#editRegisterTime").textbox("setValue", item.registerTime);
						$("#editExpectFinishDate").textbox("setValue", item.expectFinishDate);
						$("#editCustomerName").textbox("setValue", item.customerName);
						$("#editContactPerson").textbox("setValue", item.contactPerson);
						$("#editContactPersonTel").textbox("setValue", item.contactPersonTel);
						$("#editStatus").textbox("setValue", item.status);
						$("#editActualFinishTime").textbox("setValue", item.actualFinishTime);
						$("#editConsumeWorktime").textbox("setValue", item.consumeWorktime);
						$("#editProductSequenceNo").textbox("setValue", item.productSequenceNo);
						$("#editCheckTime").textbox("setValue", item.checkTime);
						$("#editReturnDate").textbox("setValue", item.returnDate);
						$("#editFinishDate").textbox("setValue", item.finishDate);
						$("#editDeliveryDate").textbox("setValue", item.deliveryDate);
						$("#editIssueReason").textbox("setValue", item.issueReason);
						$("#editHandleDescription").textbox("setValue", item.handleDescription);
						$("#editHandleCostDescription").textbox("setValue", item.handleCostDescription);
						$("#editHandleFee").textbox("setValue", item.handleFee);
						$("#editHandleCost").textbox("setValue", item.handleCost);
						$("#editRemark").textbox("setValue", item.remark);
						
						$('#editItem').window('open');
					}else{
						$.messager.alert("提示", val.msg, "error");
					}
			  	}
			});
		}
		function delItem(id){
			$.messager.confirm("删除确认", "您确定要删除所选的售后记录吗？", function(r){
				if(r){
					var params = "id=" + id;
					$.ajax({
					  	type: "GET",
					  	url: "delAftersaleRecord",
					  	data: params,
					  	success:function(data){
						  	var val = $.parseJSON(data);
							if(val.success){
								bottomRight('提示', '删除成功！');
								$('#dg').datagrid('reload');
							}else{
								$.messager.alert("提示", val.msg, "error");
							}
					  	}
					});
				}
			});
		}
		$(function(){
			$("#form").form({
				onSubmit: function(){
					var isValid = $(this).form('validate');
					return isValid;	// 返回false将停止form提交 
			    },
				success:function(data){
					var val = $.parseJSON(data);
					if(val.success){
						$('#dg').datagrid('reload');
						bottomRight('提示', '添加成功！');
						$('#addItem').window('close');
					}else{
						$.messager.alert("提示", val.msg, "error");
					}
				}
			});
			$("#editForm").form({
				onSubmit: function(){
					var isValid = $(this).form('validate');
					return isValid;	// 返回false将停止form提交 
			    },
				success:function(data){
					var val = $.parseJSON(data);
					if(val.success){
						$('#dg').datagrid('reload');
						bottomRight('提示', '修改成功！');
						$('#editItem').window('close');
					}else{
						$.messager.alert("提示", val.msg, "error");
					}
				}
			});
			//validateMenu
			search();//页面装载完成后加载数据
		});
	</script>
</body>
</html>